package csc.com.service;

import java.util.List;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import csc.com.repository.Users;

public class GetDataUser {

	 private DataSource dataSource;
	 private JdbcTemplate jdbcTemplateObject;
	 public void setDataSource(DataSource dataSource) {
		this.dataSource = dataSource;
	 }
	 public Users getUser(String loginId, String password) {
	      String SQL = "select * from users where LoginId = ? and Password = ?";
	      Users student = jdbcTemplateObject.queryForObject(SQL, 
	                        new Object[]{ loginId , password }, new UserMapper());
	      return student;
	   }

	   public List<Users> listUsers() {
	      String SQL = "select * from users";
	      List <Users> users = jdbcTemplateObject.query(SQL, 
	                                new UserMapper());
	      return users;
	   }
	 
}
